package main

import (
	"fmt"
	"io"
	"os"
	"time"
)

func main() {
	start := time.Now()
	// 写
	fWrite, err := os.Create("test1.txt")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer fWrite.Close()

	// 复制
	fRead, err := os.OpenFile("test.txt", os.O_RDONLY, 6)
	if err != nil {
		fmt.Println(err)
		return
	}
	buf := make([]byte, 1024*1024*100)
	for {
		n, err := fRead.Read(buf)
		if err != nil && err == io.EOF {
			fmt.Println("读取完毕")
			break
		}
		fWrite.Write(buf[:n])
	}
	cost := time.Since(start)
	fmt.Printf("复制完毕,程序运行时间:%s\n", cost)
}
